package com.gjy.util.quartz;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.impl.JobDetailImpl;


/**
 * 描述:
 * 任务执行类
 * sonar修改job到JobForNl
 *
 * @author flyin
 * create 2019-10-31 13:48
 */
public class JobForNl implements org.quartz.Job {

    static final  Logger LOGGER = LogManager.getLogger(JobForNl.class);

    /**
     * 执行定时任务
     *
     */
    @Override
    public void execute(JobExecutionContext jobCtx) {
        String oldName = Thread.currentThread().getName();
        try {
            JobDetail jobDetail = jobCtx.getJobDetail();
            String jobName = ((JobDetailImpl) jobDetail).getFullName();
            Thread.currentThread().setName(jobName + "_" + System.currentTimeMillis());
            LOGGER.info("定时任务{}开始执行", jobName);
            Object o = jobDetail.getJobDataMap().get("task");
            System.out.println("o = " + o);
        } finally {
            Thread.currentThread().setName(oldName);
        }
    }

}
